<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * @Date: 2022-03-26 01:16:12
 * @LastEditors: Sam
 * @LastEditTime: 2023-01-13 10:19:25
 */

use app\admin\middleware;
use app\admin\middleware\AllowOriginMiddleware;
use think\facade\Route;
use think\middleware\AllowCrossDomain;

// 允许所有域名进行跨域请求
header("Access-Control-Allow-Origin: *");



Route::miss(function() {
   echo json(['code'=>500,'msg'=>'route not found']);
    die;
});


// 登录功能
Route::group(function () {
    $common = '\\app\\admin\\controller\\';
    Route::get('/login/captcha', $common.'Login@captcha')->name('login.captcha');// 验证码
    Route::post('/login/logout', $common.'Login@logOut')->name('login.loginOut');// 退出登录
    Route::get('/login/info', $common.'Login@info')->name('login.info');// 登录信息
       // 账号管理
       Route::get('/admin_list', $common.'Admin@index')->name('admin.index');// 列表
       Route::get('/admin_log', $common.'Admin@list_log')->name('admin.log');// 管理员日志
       Route::get('/error_log', $common.'Admin@error_log')->name('admin.error');// 错误日志
       Route::post('/admin_create', $common.'Admin@create')->name('admin.create');// 创建
       Route::post('/admin_modify_password', $common.'Admin@modifyPassword')->name('admin.modifyPassword');// 密码修改
       Route::get('/admin_detail/:id', $common.'Admin@detail')->name('admin.detail')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 详情
       Route::post('/admin_update/:id', $common.'Admin@update')->name('admin.update')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 修改
       Route::post('/admin_delete/:id', $common.'Admin@delete')->name('admin.delete')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 删除
       Route::post('/admin_access/:id', $common.'Admin@access')->name('admin.access')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 授权
       Route::get('/admin_group', $common.'Admin@group')->name('admin.group');// 角色列表
       
       // 角色管理
       Route::get('/group', $common.'AuthGroup@index')->name('group.index');// 列表
       Route::post('/group_create', $common.'AuthGroup@create')->name('group.create');// 创建
       Route::get('/group_detail/:id', $common.'AuthGroup@detail')->name('group.detail')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 详情
       Route::post('/group_update/:id', $common.'AuthGroup@update')->name('group.update')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 修改
       Route::post('/group_delete/:id', $common.'AuthGroup@delete')->name('group.delete')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 删除
       Route::post('/group_access/:id', $common.'AuthGroup@access')->name('group.access')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 授权
       Route::get('/group_rule', $common.'AuthGroup@rule')->name('group.rule')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 列表
       // 权限管理
       Route::get('/rule', $common.'AuthRule@index')->name('rule.index');// 列表
       Route::post('/rule_create', $common.'AuthRule@create')->name('rule.create');// 创建
       Route::get('/rule_detail/:id', $common.'AuthRule@detail')->name('rule.detail')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 详情
       Route::post('/rule_update/:id', $common.'AuthRule@update')->name('rule.update')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 修改
       Route::post('/rule_delete/:id', $common.'AuthRule@delete')->name('rule.delete')->pattern(['id'=>'[A-Za-z0-9]{32}']);// 删除

      // 用户管理
      Route::get('/user_index', $common.'User@index')->name('user.index');// 列表
      Route::get('/user_detail', $common.'User@detail')->name('user.detail');// 详情
      Route::post('/user_edit', $common.'User@edit')->name('user.edit');// 编辑
      Route::post('/user_create', $common.'User@create')->name('user.create');// 创建  

      Route::post('/user_import_excell', $common.'User@user_import_excell')->name('user.user_import_excell');// 导入
    

      //代码构建
      Route::get('/curd_index', $common.'Curd@index')->name('curd.index');// 查询  
      Route::post('/curd_run', $common.'Curd@run')->name('curd.run');// 提交

      Route::post('/upload', $common.'Upload@upload_file')->name('upload.upload_file');// 上传类
    
      Route::get('/get_video_signature', $common.'Upload@get_signature')->name('upload.upload_file');// 获取视频上传配置类
      Route::post('/user_export_excell', $common.'User@export_excell')->name('user.export');// 导出
      Route::post('/import', $common.'User@import_excell')->name('user.import');// 导入

      //插件
      Route::get('/plugin_index', $common.'Plugin@index')->name('plugin.index');// 插件列表
      Route::post('/plugin_install', $common.'Plugin@install')->name('plugin.index');// 安装插件

      Route::get('/get_settings', $common.'Settings@index')->name('settings.index');// 获取配置  
      Route::post('/handle_settings', $common.'Settings@set_handle')->name('settings.handle_settings');//提交配置

      Route::get('/merchant_list', $common.'Merchant@list')->name('merchant.list');// 商家列表 
      Route::get('/merchant_detail', $common.'Merchant@detail')->name('merchant.detail');// 商家详情
      Route::post('/merchant_approve', $common.'Merchant@approve')->name('merchant.detail');// 商家审核通过
      Route::post('/merchant_reject', $common.'Merchant@reject')->name('merchant.reject');// 商家审核拒绝
      Route::post('/merchant_delete', $common.'Merchant@delete')->name('merchant.delete');// 商家删除
      Route::get('/withdrawal_list', $common.'Merchant@withdrawal_list')->name('merchant.withdrawal');// 提现列表
      
      Route::post('/merchant_withdrawal_approve', $common.'Merchant@withdrawal_approve')->name('merchant.withdrawal_approve');// 商家审核通过
      Route::post('/merchant_withdrawal_reject', $common.'Merchant@withdrawal_reject')->name('merchant.withdrawal_reject');// 商家审核拒绝


    //代码示例
    Route::group(function () {
        $common = "\\app\\admin\\controller\\";
        Route::get("/demo_index", "app\admin\controller\Demo@index")->name("demo.edit");// 列表
        Route::get("/demo_detail", "app\admin\controller\Demo@detail")->name("demo.detail");// 详情
        Route::post("/demo_delete", "app\admin\controller\Demo@delete")->name("demo.delete");// 删除
        Route::post("/demo_create", "app\admin\controller\Demo@create")->name("demo.create");// 创建  
        Route::post("/demo_edit", "app\admin\controller\Demo@edit")->name("demo.edit");
        Route::post('/demo_import', $common."Demo@import_excell")->name("demo.import");// 导入
    });
})
->allowCrossDomain()
->middleware(middleware\Auth::class)// jwt认证
->middleware(middleware\Permission::class);// 权限认证


Route::group(function () {
    //无需用户验证的路由
    $common = '\\app\\admin\\controller\\';

  
    Route::post('/login', $common.'Login@login')->name('login.login');
    Route::post('/editor/upload', $common.'Upload@editor_upload_file')->name('upload.editor_upload_file');// 编辑器上传类
    Route::post('/upload_file', $common.'Upload@upload_file')->name('upload.upload_file');// 通用上传类
    Route::get('/welcome', $common.'Welcome@index')->name('welcome.index');
    Route::get('/user_export_excell', $common.'User@user_export_excell')->name('user.user_export_excell');// 用户导出
    Route::get('/demo_export', $common."Demo@export_excell")->name("demo.export");// demo导出
  
})
->allowCrossDomain();// 跨域






Route::group(function () {
    //商城
        Route::get("/category_index", "app\admin\controller\StoreCategory@index")->name("goods.category_index");// 分类列表
        Route::post("/category_create", "app\admin\controller\StoreCategory@create")->name("goods.category_create");// 分类添加
        Route::post("/category_edit", "app\admin\controller\StoreCategory@edit")->name("goods.category_edit");// 分类编辑
        Route::post("/category_delete", "app\admin\controller\StoreCategory@delete")->name("goods.category_delete");// 分类删除
        Route::get("/category_detail", "app\admin\controller\StoreCategory@detail")->name("goods.category_detail"); //分类详情

        Route::get("/goods_rule_index", "app\admin\controller\ProductRule@index")->name("goods.rule_index");// 规格列表
        Route::post("/goods_rule_create", "app\admin\controller\ProductRule@create")->name("goods.rule_create");// 规格创建
        Route::get("/goods_rule_detail", "app\admin\controller\ProductRule@detail")->name("goods.rule_detail");// 规格详情
        Route::post("/goods_rule_edit", "app\admin\controller\ProductRule@edit")->name("goods.rule_edit");// 规格详情

        Route::get("/goods_index", "app\admin\controller\Goods@index")->name("goods.index");// 商品列表
        Route::post("/goods_create", "app\admin\controller\Goods@create")->name("goods.create");// 商品创建
        Route::get("/goods_detail", "app\admin\controller\Goods@get_product_info")->name("goods.detail");// 商品详情
        Route::post("/goods_edit", "app\admin\controller\Goods@edit")->name("goods.edit");// 商品编辑
        Route::post("/goods_delete", "app\admin\controller\Goods@del")->name("goods.delete");// 商品删除
        Route::post("/goods_format", "app\admin\controller\Goods@is_format_attr")->name("goods.format");// 商品属性生成
        Route::post("/goods_approve", "app\admin\controller\Goods@goods_approve")->name("goods.goods_approve");// 审核
        Route::post("/goods_reject", "app\admin\controller\Goods@goods_reject")->name("goods.goods_reject");// 审核
    
        Route::get("/order_index", "app\admin\controller\Order@index")->name("order.index");// 订单列表
        Route::get("/order_detail", "app\admin\controller\Order@detail")->name("order.detail");// 订单详情
        Route::post("/order_edit", "app\admin\controller\Order@edit")->name("order.edit");// 订单编辑
        Route::post("/order_deliver", "app\admin\controller\Order@deliver")->name("order.deliver");// 订单发货
        Route::post("/order_refundyes", "app\admin\controller\Order@refund_y")->name("order.refund_y");// 订单审核通过
        Route::post("/order_refundno", "app\admin\controller\Order@refund_n")->name("order.refund_n");// 订单审核拒绝
        Route::get("/order_log", "app\admin\controller\Order@order_log")->name("order.log");// 订单日志
        Route::post("/order_export", "app\admin\controller\Order@export")->name("survey.export");// 订单导出

        Route::get("/coupon_template_index", "app\admin\controller\CouponTemplate@index")->name("marketing.coupon_template");// 优惠券模板列表
        Route::post("/coupon_template_add", "app\admin\controller\CouponTemplate@create")->name("marketing.coupon_template_add");// 优惠券模板添加
        Route::post("/coupon_template_create", "app\admin\controller\CouponTemplate@create")->name("marketing.coupon_template_create");// 优惠券模板创建
        Route::get("/coupon_template_detail", "app\admin\controller\CouponTemplate@detail")->name("marketing.coupon_template_detail");// 优惠券模板详情
        Route::post("/coupon_template_edit", "app\admin\controller\CouponTemplate@edit")->name("marketing.coupon_template_edit");// 优惠券模板编辑
        Route::post("/coupon_template_delete", "app\admin\controller\CouponTemplate@delete")->name("marketing.coupon_template_delete");// 优惠券模板删除
        Route::post("/coupon_template_issue", "app\admin\controller\CouponTemplate@issue")->name("marketing.coupon_template_issue");// 优惠券发布
        Route::get("/coupon_index", "app\admin\controller\Coupon@index")->name("marketing.coupon_index");// 优惠券列表    
        Route::get("/coupon_log", "app\admin\controller\Coupon@coupon_log")->name("marketing.coupon_log");// 优惠券领取记录
        Route::post("/coupon_delete", "app\admin\controller\Coupon@delete")->name("marketing.coupon_delete");// 优惠券删除
        Route::get("/coupon_user", "app\admin\controller\Coupon@coupon_user")->name("marketing.coupon_user");// 优惠券领取记录

        Route::get('/get_echarts_order', 'app\admin\controller\Record@get_echarts_order')->name('record.get_echarts_order'); //数据统计 订单数据
        Route::get('/get_echarts_product', 'app\admin\controller\Record@get_echarts_product')->name('record.get_echarts_product'); //数据统计 商品数据
        Route::get('/get_echarts_collection','app\admin\controller\Record@get_echarts_collection')->name('record.get_echarts_collection'); //数据统计 商品收藏数据
        Route::get('/get_echarts_profity', 'app\admin\controller\Record@get_echarts_profity')->name('record.get_echarts_profity'); //数据统计 商品销售数据
        Route::get('/get_echarts_stock', 'app\admin\controller\Record@get_echarts_stock')->name('record.get_echarts_stock'); //数据统计 商品库存数据
        Route::get('/getTuiPriesList', 'app\admin\controller\Record@getTuiPriesList')->name('record.getTuiPriesList'); //数据统计 商品退货数据
    })
    ->allowCrossDomain()// 跨域
    ->middleware(middleware\Auth::class)// jwt认证
    ->middleware(middleware\Permission::class);// 权限认证

    //分销员
    Route::group(function () {
        $common = "\\app\\admin\\controller\\";
        Route::get("/distributor_index", "app\admin\controller\Distributor@index")->name("distributor.index");// 列表
        Route::get("/distributor_detail", "app\admin\controller\Distributor@detail")->name("distributor.detail");// 详情
        Route::post("/distributor_delete", "app\admin\controller\Distributor@delete")->name("distributor.delete");// 删除
        Route::post("/distributor_create", "app\admin\controller\Distributor@create")->name("distributor.create");// 创建  
        Route::post("/distributor_yes", "app\admin\controller\Distributor@yes")->name("distributor.yes");// 审核通过
        Route::post("/distributor_no", "app\admin\controller\Distributor@no")->name("distributor.no");// 审核拒绝
        Route::post("/distributor_edit", "app\admin\controller\Distributor@edit")->name("distributor.edit");
        Route::get("/user_commission_index","app\admin\controller\UserCommission@index")->name("user_commission.index"); //分销订单
        Route::get("user_commission_export","app\admin\controller\UserCommission@user_commission_export")->name("user_commission.user_commission_export"); //分销订单导出
        
    })

    
->allowCrossDomain() // 跨域
->middleware(middleware\Auth::class)// jwt认证
->middleware(middleware\Permission::class);// 权限认证


    //提现
    Route::group(function () {
        Route::get("/withdrawal_index", "app\admin\controller\Withdrawal@index")->name("withdrawal.edit");// 列表 
        Route::post("/withdrawal_yes", "app\admin\controller\Withdrawal@yes")->name("withdrawal.yes");// 审核通过
        Route::post("/withdrawal_no", "app\admin\controller\Withdrawal@no")->name("withdrawal.no");// 审核拒绝
        Route::get("user_withdrawal_export","app\admin\controller\Withdrawal@user_withdrawal_export")->name("withdrawal.user_withdrawal_export"); //分销订单导出
        
    })

        
    ->allowCrossDomain() // 跨域
    ->middleware(middleware\Auth::class)// jwt认证
    ->middleware(middleware\Permission::class);// 权限认证//轮播图
Route::group(function () {
        Route::get("/banner_index", "app\admin\controller\Banner@index")->name("banner.index");// 列表
        Route::get("/banner_detail", "app\admin\controller\Banner@detail")->name("banner.detail");// 详情
        Route::post("/banner_delete", "app\admin\controller\Banner@delete")->name("banner.delete");// 删除
        Route::post("/banner_create", "app\admin\controller\Banner@create")->name("banner.create");// 创建  
        Route::post("/banner_edit", "app\admin\controller\Banner@edit")->name("banner.edit");// 编辑
    })
->allowCrossDomain()// 跨域
->middleware(middleware\Auth::class)// jwt认证
->middleware(middleware\Permission::class);// 权限认证
    Route::group(function () {
        //艺术家
            $common = "\\app\\admin\\controller\\";
            Route::get("/artist_index", "app\admin\controller\Artist@index")->name("artist.index");// 列表
            Route::get("/artist_detail", "app\admin\controller\Artist@detail")->name("artist.detail");// 详情
            Route::post("/artist_delete", "app\admin\controller\Artist@delete")->name("artist.delete");// 删除
            Route::post("/artist_create", "app\admin\controller\Artist@create")->name("artist.create");// 创建  
            Route::post("/artist_edit", "app\admin\controller\Artist@edit")->name("artist.edit");
            
        })
    ->allowCrossDomain() // 跨域
    ->middleware(middleware\Auth::class)// jwt认证
    ->middleware(middleware\Permission::class);// 权限认证

//运费模板
Route::group('shipping', function() {
    Route::get('template', 'ShippingTemplate/index');
    Route::post('template', 'ShippingTemplate/create');
    Route::put('template/:id', 'ShippingTemplate/update');
    Route::post('updateTemplateStatus/:id', 'ShippingTemplate/updateTemplateStatus');
    Route::delete('template/:id', 'ShippingTemplate/delete');
    Route::get('regions', 'ShippingTemplate/regions');
})->allowCrossDomain()
->middleware(middleware\Auth::class)// jwt认证
->middleware(middleware\Permission::class);// 权限认证;
        